import { _decorator, Camera, Component, EventTouch, find, input, Input, Node, v3, Vec3, view } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('Test')
export class Test extends Component {
    private camera: Camera;
    start() {
       this.camera = find('Main Camera').getComponent(Camera)
       console.log(this.camera)
       console.log(this.camera.rect)
       console.log(view.getVisibleSize())
       let size = view.getVisibleSize()
       let width = size.width
       let height = size.height


       input.on(Input.EventType.TOUCH_START, this.onTouchStart, this)
       
    }

    onTouchStart(event: EventTouch){
        const touch = event.touch!;
        let x = touch.getLocationX()
        let y = touch.getLocationY()
        console.log(x)
        console.log(y)

        let pos = this.camera.screenToWorld(v3(x, y, 0))
        console.log(pos)
    }

    update(deltaTime: number) {
        
    }
}


